﻿using System;
using System.Collections.Generic;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Qcdz.Domain.Shops;

namespace Ue.Qcdz.Domain.ShopSinglePages
{
    /// <summary>
    /// 店铺单页文章
    /// </summary>
    public class ShopSinglePageService
    {
        private static IShopSinglePageRepository repository;

        static ShopSinglePageService()
        {
            ShopSinglePageService.repository = RepositoryFactory.GetRepository<IShopSinglePageRepository, ShopSinglePage>();
        }
        public static ShopSinglePage GetShopSinglePage(object shopSinglePageKey)
        {
            return ShopSinglePageService.repository.FindBy(shopSinglePageKey);
        }

        public static IList<ShopSinglePage> GetShopSinglePage()
        {
            return ShopSinglePageService.repository.FindAll();
        }
        public static IDataResult<ShopSinglePage> GetShopSinglePage(IShopSinglePageDataQuery dataQuery)
        {
            return ShopSinglePageService.repository.FindBy(dataQuery);
        }

        public static void AddShopSinglePage(ShopSinglePage shopSinglePage)
        {
            ShopSinglePageService.repository.Add(shopSinglePage);
        }

        public static void RemoveShopSinglePage(ShopSinglePage shopSinglePage)
        {
            ShopSinglePageService.repository.Remove(shopSinglePage);
        }
        public static void RemoveShopSinglePage(object shopSinglePageKey)
        {
            ShopSinglePage shopSinglePage = ShopSinglePageService.repository.FindBy(shopSinglePageKey);
            if (shopSinglePage == null)
            {
                throw new ArgumentOutOfRangeException("shopSinglePageKey");
            }

            ShopSinglePageService.repository.Remove(shopSinglePage);
        }

        public static void UpdateShopSinglePage(ShopSinglePage shopSinglePage)
        {
            ShopSinglePageService.repository[shopSinglePage.Key] = shopSinglePage;
        }
        public static ShopSinglePage GetSinglePage(string title, Shop shop)
        {
            return ShopSinglePageService.repository.GetSinglePage(title, shop);
        }
        public static void RemoveAll(Shop shop)
        {
            ShopSinglePageService.repository.RemoveAll(shop);
        }

    }
}
